<?php

namespace Modules\Api\Http\Controllers;

use Illuminate\Http\Request;
use Modules\Api\Service\MallOrderService;

class MallOrderController extends BaseController
{
    /**
     * 结算台--预生成积分订单
     *
     * 2019 11 26
     */
    public function pre_build_order_mall(Request $request)
    {
        $arr_input = $request->all();

        $res = MallOrderService::pre_build_order((array)$arr_input, false);

        return response_json($res);
    }


    /**
     * 生成积分订单
     *
     * 2019 11 26
     */
    public function create_mall_order(Request $request)
    {
        $arr_input = $request->all();
        $arr_input['user_id'] = api_user_id(); //用户id

        shiwu_start();
        $res = MallOrderService::create_mall_order((array)$arr_input);
        shiwu_end($res);

        return response_json($res);
    }

    /**
     * 支付订单
     *
     * 2019 11 26
     */
    public function pay_mall_order(Request $request)
    {
        $arr_input = $request->all();
        $arr_input['user_id'] = api_user_id(); //用户id
        shiwu_start();
        $res = MallOrderService::pay_mall_order((array)$arr_input);
        shiwu_end($res);

        return response_json($res);
    }


    /**
     * 获取用户订单列表
     *
     * 2019 11 26
     */
    public function get_mall_order_list(Request $request)
    {
        $arr_input = $request->all();
        $arr_input['user_id'] = api_user_id(); //用户id

        $res = MallOrderService::get_mall_order_list((array)$arr_input);

        return response_json($res);
    }


    /**
     * 获取订单详情
     *
     * 2019 11 27
     */
    public function get_mall_order_info(Request $request)
    {
        $arr_input = $request->all();

        $res = MallOrderService::get_mall_order_info((array)$arr_input);

        return response_json($res);
    }

    /**
     * 确认收货
     *
     * 2019 11 28
     */
    public function mall_order_take_over(Request $request)
    {
        $arr_input = $request->all();
        $arr_input['user_id'] = api_user_id(); //用户id

        $res = MallOrderService::mall_order_take_over((array)$arr_input);

        return response_json($res);
    }

    /**
     * 取消订单
     *
     * 2020 01 09
     */
    public function cancel_mall_order(Request $request)
    {
        $arr_input = $request->all();
        $arr_input['user_id'] = api_user_id(); //用户id

        $res = MallOrderService::cancel_mall_order((array)$arr_input);

        return response_json($res);
    }


    /**
     * 删除订单
     *
     * 2020 01 09
     */
    public function del_mall_order(Request $request)
    {
        $arr_input = $request->all();
        $arr_input['user_id'] = api_user_id(); //用户id

        $res = MallOrderService::del_mall_order((array)$arr_input);

        return response_json($res);
    }
}